<?php
namespace app\adm\controller;
use think\Controller;
use think\Db;
use think\Request;

class Mail extends Index
{
	public function __construct(Request $request){
		parent::__construct($request);
	}
	/**
	* 站内信列表
	*/
	public function maillist(){
		$page = Db::name('mail')->paginate(8,false,['type'=>'bootstrap','var_page'=>'page',]);
		$maillist = $page->all();
		foreach ($maillist as $key => $value) {
			$maillist[$key]['nickname'] = Db::name('user')->where(['userid'=>$maillist[$key]['userid']])->value('nickname');
		}
		$this->assign('page',$page);
		$this->assign('maillist',$maillist);
		return $this->fetch('maillist',['title'=>'站内信列表']);
	}
	//删除站内信
	public function maildel(){
		$mailid = input('mailid');
		$res = Db::name('mail')->delete($mailid);
		// dump($res);die;
		if($res){
			$this->success('删除成功');
		}else{
			$this->assign('删除失败');
		}
	}
}